

def form_html(key,key_type,data):
    if key == 'data':
        return ''
    # print('form_html',key_type,type(key_type))
    if key_type == str:
        if key in ['xField','yField','seriesField']:
            return special_keyword(key,data)
        str_ = f'''
        <el-form-item label="{key}" prop="{key}" size="mini">
            <el-input v-model="{key}"></el-input>
        </el-form-item>
        '''
        return str_
    if key_type ==  bool:
        str_ = f'''
        <el-form-item label="{key}" prop="{key}">
            <el-switch v-model="{key}"></el-switch>
        </el-form-item>
        '''
        return str_
    
    if key_type == int or key_type == float :
        str_ = f'''
        <div class="block">
            <span class="demonstration">{key}</span>
            <el-slider
                v-model="{key}"
                show-input>
            </el-slider>
        </div>
        '''
        return str_
    
    return ''

def special_keyword(key,data):
    if key in ['xField','yField','seriesField']:
        str_ = f'''
        <el-form-item label="{key}">
        <el-select v-model="{key}" placeholder="请选择你的字段作为{key}轴">
        '''
        for data_key in data[0].keys():
            str_ += f'''
            <el-option label="{data_key}" value="{data_key}" />
            '''
        str_ += '''
            </el-select>
        </el-form-item>
        '''
        return str_
    

def get_form_tags(set_options):
    html_ = ""
    for key in set_options.keys():
        if type(set_options[key]) ==dict:
            for key1 in set_options[key].keys():
                # print(key1,type(set_options[key][key1]))
                html_ += form_html(f'{key}_{key1}',type(set_options[key][key1]),set_options['data'])
                # print(form_html(f'{key}_{key1}',type(set_options[key][key1]),set_options['data']))
            continue
        # print(key,type(set_options[key]))
        html_ += form_html(key,type(set_options[key]),set_options['data'])
        # print(form_html(key,type(set_options[key]),set_options['data']))
    return html_.replace('\n','').strip()

